package com.youpai.platform.jarvis.exceptions;


import com.youpai.platform.jarvis.enums.ProcessCodeEnum;

/**
 * @time: 2021/8/11 7:32 下午
 * @author: welles
 * @description: 异常类
 */
public class AppException extends RuntimeException {

    private static final long serialVersionUID = -8000265430103844079L;
    private ProcessCodeEnum error;

    public AppException(Throwable cause) {
        super(cause);
    }

    public AppException(String message) {
        super(message);
    }

    public AppException(ProcessCodeEnum error) {
        super(error.getDesc());
        this.error = error;
    }

    public String getCode() {
        return error == null ? "" : error.getCode();
    }

    public ProcessCodeEnum getError() {
        return error;
    }

    @Override
    public String toString() {
        return error != null ? error.toString() : super.toString();
    }
}
